package com.example.todolist.service;

import com.example.todolist.mapper.VerificationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
//验证码接受器
@Service
public class VerificationService {
    @Autowired
    private VerificationMapper verificationMapper;
    public Boolean find(String name)
    {
        if(verificationMapper.find(name)!=0)
        {
            return true;
        }
        return false;
    }

    public Integer getTheNumber(String name)
    {
        if(verificationMapper.find(name)==1)
        {
            return verificationMapper.getTheNumber(name);
        }
        else
        {
            return 0;
        }
    }

    public void Insert(String name,Integer number)
    {
        if(find(name))
        {
            verificationMapper.update(name,number);
        }
        verificationMapper.Insert(name,number);
    }

    public void DeleteTheNumber(String name)
    {
        verificationMapper.deleteTheNumber(name);
    }
}
